<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
</head>

<body>
  <div>
    <p id="pp"></p>
    <button onclick="doIt()">click</button>
    <img id="img1" src="../images/001.png" />
  </div>
  <script>
    var aaa = "";
    window.onload = function () {
      getEle();
    }

    function getEle() {
      this.aaa = document.getElementById("img1");
    }

    function doIt() {
      this.aaa.src="../images/002.png";
    }
  </script>

</body>

</html>